package org.zpmis.domain.role.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
import org.zpmis.domain.role.model.SysMenu;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
public class SysMenuListVo implements Serializable {
    /**
     * 主键
     */
    private Long id;

    /**
     * 名称
     */
    private String name;

    /**
     * 上级菜单唯一标识
     */
    private String parentMenuKey;

    /**
     * 菜单唯一标识
     */
    private String menuKey;

    /**
     * 菜单类型 0：按钮  1：菜单
     */
    private Integer type;

    /**
     * 菜单分级 0：一级 1：二级
     */
    private Integer menuCate;

    /**
     * 图标
     */
    private String icon;

    /**
     * 排序
     */
    private Integer sort;

    /**
     * 其含义为父级节点的id
     */
    private Long parentId;

    /**
     * 如果类型type为1时候菜单有路由 此值为路由地址
     */
    private String routerUrl;


    /**
     * 是否禁用 0禁用 1启用
     */
    private Integer status;

    /**
     * 菜单分组
     */
    private String menuGroup;
    /**
     * 该菜单下的子菜单
     */
    @JsonInclude(value = JsonInclude.Include.NON_EMPTY)
    private List<SysMenuListVo> childList = new ArrayList<>();

    /**
     * 该菜单下的按钮
     */
    @JsonInclude(value = JsonInclude.Include.NON_EMPTY)
    private List<SysMenuListVo> childButtonList = new ArrayList<>();

    public SysMenuListVo(SysMenu sysMenu) {
        this.id = sysMenu.getId();
        this.name = sysMenu.getName();
        this.menuKey = sysMenu.getMenuKey();
        this.type = sysMenu.getType();
        this.menuCate = sysMenu.getMenuCate();
        this.icon = sysMenu.getIcon();
        this.sort = sysMenu.getSort();
        this.parentId = sysMenu.getParentId();
        this.routerUrl = sysMenu.getRouterUrl();
        this.status = sysMenu.getStatus();
        this.menuGroup = sysMenu.getMenuGroup();
        this.parentMenuKey = sysMenu.getParentMenuKey();
    }
}